/*
 * @Description:
 * @Author: xiongkuobiao
 * @Date: 2022-08-01 08:59:25
 * @LastEditors: xiongkuobiao
 * @LastEditTime: 2024-01-08 17:47:25
 */
import {
  getHomeHotSuggests,
  getHomeCategories,
  getHomeHouselist,
} from "@/services"
import { defineStore } from "pinia"

const useHomeStore = defineStore("home", {
  state: () => ({
    hotSuggests: [],
    categories: [],
    currentPage: 1,
    houselist: [],
  }),
  actions: {
    async fetchHotSuggestData() {
      const res = await getHomeHotSuggests()
      this.hotSuggests = res.data
    },
    async fetchCategoriesData() {
      const res = await getHomeCategories()
      this.categories = res.data
    },
    async fetchHouselistData() {
      const res = await getHomeHouselist(this.currentPage)
      this.houselist.push(...res.data)
      this.currentPage++
    },
  },
})

export default useHomeStore
